package GUILayer;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.JDesktopPane;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JRadioButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.JTable;
import javax.swing.border.BevelBorder;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.JScrollPane;
import javax.swing.JCheckBox;
import java.awt.Color;

public class Sales {

	private JFrame frame;
	private JTable table;
	private JTable table_1;

	/**
	 * Launch the application.
	 */
	public static void main() {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Sales window = new Sales();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Sales() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 639, 500);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setBounds(0, 0, 623, 462);
		frame.getContentPane().add(tabbedPane);
		
		JPanel saleTab = new JPanel();
		tabbedPane.addTab("Sale", null, saleTab, null);
		saleTab.setLayout(null);
		
		JTextArea saleIDtxt = new JTextArea();
		saleIDtxt.setBounds(87, 23, 101, 19);
		saleIDtxt.setToolTipText("\r\n");
		saleTab.add(saleIDtxt);
		
		JLabel lblSaleId = new JLabel("Sale ID");
		lblSaleId.setBounds(10, 21, 47, 29);
		saleTab.add(lblSaleId);
		
		JLabel lblCustomerId = new JLabel("Customer ID");
		lblCustomerId.setBounds(10, 53, 77, 29);
		saleTab.add(lblCustomerId);
		
		JLabel lblDateCreated = new JLabel("Date Created");
		lblDateCreated.setBounds(208, 22, 77, 27);
		saleTab.add(lblDateCreated);
		
		JLabel lblDeliveryDate = new JLabel("Delivery Date");
		lblDeliveryDate.setBounds(208, 53, 79, 29);
		saleTab.add(lblDeliveryDate);
		
		JTextArea saleCutomerID = new JTextArea();
		saleCutomerID.setBounds(87, 56, 101, 19);
		saleTab.add(saleCutomerID);
		
		JTextArea saleDateCreated = new JTextArea();
		saleDateCreated.setBounds(293, 23, 136, 19);
		saleTab.add(saleDateCreated);
		
		JTextArea saleDeliveryDate = new JTextArea();
		saleDeliveryDate.setBounds(293, 55, 139, 19);
		saleTab.add(saleDeliveryDate);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 160, 598, 121);
		saleTab.add(scrollPane);
		
		table = new JTable();
		scrollPane.setViewportView(table);
		table.setCellSelectionEnabled(true);
		table.setFillsViewportHeight(true);
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"Product ID", "Price", "Name", "Country of Origin"
			}
		) {
			boolean[] columnEditables = new boolean[] {
				false, true, true, true
			};
			public boolean isCellEditable(int row, int column) {
				return columnEditables[column];
			}
		});
		table.getColumnModel().getColumn(1).setPreferredWidth(100);
		table.getColumnModel().getColumn(2).setPreferredWidth(100);
		table.getColumnModel().getColumn(3).setPreferredWidth(100);
		table.setColumnSelectionAllowed(true);
		
		JLabel lblDiscount = new JLabel("Discount");
		lblDiscount.setForeground(Color.BLACK);
		lblDiscount.setBounds(10, 292, 64, 22);
		saleTab.add(lblDiscount);
		
		JTextArea saleDiscount = new JTextArea();
		saleDiscount.setForeground(Color.BLUE);
		saleDiscount.setBounds(69, 291, 72, 23);
		saleTab.add(saleDiscount);
		
		JButton saleDeletAll = new JButton("Delete ALL");
		saleDeletAll.setBounds(10, 394, 131, 29);
		saleTab.add(saleDeletAll);
		
		JButton saleFinish = new JButton("Finish");
		saleFinish.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				frame.dispose();
			}
		});
		saleFinish.setBounds(482, 374, 126, 49);
		saleTab.add(saleFinish);
		
		JCheckBox chckbxPrintInvoice = new JCheckBox("Print Invoice");
		chckbxPrintInvoice.setBounds(482, 344, 126, 23);
		saleTab.add(chckbxPrintInvoice);
		
		JTextArea saleCustomerInfo = new JTextArea();
		saleCustomerInfo.setBounds(460, 23, 148, 104);
		saleTab.add(saleCustomerInfo);
		
		JLabel lblCustomerInfo = new JLabel("Customer Info");
		lblCustomerInfo.setBounds(460, 0, 148, 19);
		saleTab.add(lblCustomerInfo);
		
		JButton saleDeleteSelected = new JButton("Delete Selected");
		saleDeleteSelected.setBounds(10, 354, 131, 29);
		saleTab.add(saleDeleteSelected);
		
		JLabel lblTotalPrice = new JLabel("Total Price");
		lblTotalPrice.setBounds(208, 292, 77, 22);
		saleTab.add(lblTotalPrice);
		
		JTextArea saleTPrice = new JTextArea();
		saleTPrice.setForeground(Color.RED);
		saleTPrice.setBounds(293, 291, 101, 22);
		saleTab.add(saleTPrice);
		
		JPanel loanTab = new JPanel();
		tabbedPane.addTab("Loan", null, loanTab, null);
		loanTab.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("Loan ID");
		lblNewLabel.setBounds(10, 13, 65, 21);
		loanTab.add(lblNewLabel);
		
		JLabel lblCustomerId_1 = new JLabel("Customer ID");
		lblCustomerId_1.setBounds(10, 50, 65, 21);
		loanTab.add(lblCustomerId_1);
		
		JLabel lblDateCreated_1 = new JLabel("Date Created");
		lblDateCreated_1.setBounds(205, 13, 92, 21);
		loanTab.add(lblDateCreated_1);
		
		JLabel lblDeliveryDate_1 = new JLabel("Delivery Date");
		lblDeliveryDate_1.setBounds(205, 47, 92, 18);
		loanTab.add(lblDeliveryDate_1);
		
		JLabel lblReturningDate = new JLabel("Returning Date");
		lblReturningDate.setBounds(205, 82, 92, 21);
		loanTab.add(lblReturningDate);
		
		JLabel lblCustomerInfo_1 = new JLabel("Customer Info");
		lblCustomerInfo_1.setBounds(458, 0, 108, 21);
		loanTab.add(lblCustomerInfo_1);
		
		JTextArea loanIDtxt = new JTextArea();
		loanIDtxt.setBounds(85, 11, 92, 21);
		loanTab.add(loanIDtxt);
		
		JTextArea loanCustomerID = new JTextArea();
		loanCustomerID.setBounds(85, 48, 93, 21);
		loanTab.add(loanCustomerID);
		
		JTextArea loanDateCreated = new JTextArea();
		loanDateCreated.setBounds(307, 11, 92, 22);
		loanTab.add(loanDateCreated);
		
		JTextArea loanDeliveryDate = new JTextArea();
		loanDeliveryDate.setBounds(307, 44, 92, 22);
		loanTab.add(loanDeliveryDate);
		
		JTextArea loanReturningDate = new JTextArea();
		loanReturningDate.setBounds(307, 80, 92, 22);
		loanTab.add(loanReturningDate);
		
		JTextArea loanCustomerInfo = new JTextArea();
		loanCustomerInfo.setBounds(458, 23, 150, 103);
		loanTab.add(loanCustomerInfo);
		
		JScrollPane scrollPane_1 = new JScrollPane();
		scrollPane_1.setBounds(10, 165, 598, 120);
		loanTab.add(scrollPane_1);
		
		table_1 = new JTable();
		scrollPane_1.setViewportView(table_1);
		table_1.setModel(new DefaultTableModel(
			new Object[][] {
				
			},
			new String[] {
				"Product ID", "Price", "Name", "Country of Origin"
			}
		));
		
		JLabel lblDiscount_1 = new JLabel("Discount");
		lblDiscount_1.setBounds(17, 296, 58, 21);
		loanTab.add(lblDiscount_1);
		
		JTextArea loanDiscount = new JTextArea();
		loanDiscount.setBounds(85, 296, 81, 23);
		loanTab.add(loanDiscount);
		
		JLabel lblTotalPrice_1 = new JLabel("Total Price");
		lblTotalPrice_1.setBounds(232, 297, 65, 18);
		loanTab.add(lblTotalPrice_1);
		
		JTextArea loanTPrice = new JTextArea();
		loanTPrice.setBounds(307, 294, 92, 25);
		loanTab.add(loanTPrice);
		
		JButton loanDeleteSelected = new JButton("Delete Selected");
		loanDeleteSelected.setBounds(10, 358, 134, 27);
		loanTab.add(loanDeleteSelected);
		
		JButton loanDeleteAll = new JButton("Delete ALL");
		loanDeleteAll.setBounds(10, 396, 134, 27);
		loanTab.add(loanDeleteAll);
		
		JButton loanFinish = new JButton("Finish");
		loanFinish.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.dispose();
			}
		});
		loanFinish.setBounds(478, 374, 130, 49);
		loanTab.add(loanFinish);
		
		JCheckBox chckbxPrintInvoice_1 = new JCheckBox("Print Invoice");
		chckbxPrintInvoice_1.setBounds(478, 344, 97, 23);
		loanTab.add(chckbxPrintInvoice_1);
		
		JLabel lblLoanPeriod = new JLabel("Loan Period");
		lblLoanPeriod.setToolTipText("Number of Days");
		lblLoanPeriod.setBounds(10, 85, 76, 21);
		loanTab.add(lblLoanPeriod);
		
		JTextArea loanNoOfDays = new JTextArea();
		loanNoOfDays.setText("Number of Days");
		loanNoOfDays.setBounds(86, 82, 92, 21);
		loanTab.add(loanNoOfDays);
		table_1.getColumnModel().getColumn(1).setPreferredWidth(100);
		table_1.getColumnModel().getColumn(2).setPreferredWidth(100);
		table_1.getColumnModel().getColumn(3).setPreferredWidth(115);
	}
}
